package com.rock.code.updatedbtime.services.impl;

import com.rock.code.updatedbtime.services.UpdateDbTimeService;
import org.apache.log4j.Logger;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * TODO
 * <p/>
 * Created by kongqiang
 * Date 16/3/13
 */
public class UpdateDbTimeServiceImpl implements UpdateDbTimeService {

    public Logger logger = Logger.getLogger("schedule");

    @Override
    public void updateDbTime(String timeKey) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String dateStr = sdf.format(new Date());
        try {
            Calendar ca= Calendar.getInstance();
            ca.setTime(sdf.parse(dateStr));
            ca.add(Calendar.MINUTE, 1);
            logger.info("db time update to "+ca.getTime());
//            RedisAPI.setObj(timeKey, ca.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
